﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OF.Utility;
using OF.Utility.Logging;

using Common.Logging;

namespace OF.Utility.Logging
{
    /// <summary>
    /// 业务日志记录器
    /// </summary>
    public abstract class BizLogHelper
    {
        private const string BizLoggerName = "BizLogAdoNetAppenderLogger";
        public static void Operate(BusinessLog businessLogInfo)
        {
            ILog logger = LogManager.GetLogger(BizLoggerName);
            logger.Fatal(businessLogInfo);
        }
        //public static void Operate(int PlatformID, string moduleName, string methodName, string targetID, string actionInfo)
        //{
        //    System.Reflection.MethodBase methodInfo = new System.Diagnostics.StackFrame(1).GetMethod();
        //    ILog logger = LogManager.GetLogger("OF.Component");
        //    logger.Fatal(new BusinessLog()
        //    {
        //        ModuleName = moduleName,
        //        MethodName = methodName,
        //        TargetID = targetID,
        //        OpContent = actionInfo,
        //        OpUserName = UserHelper.GetUserIdentity(),
        //        ServerName = UserHelper.GetServerName(),
        //        ClientIP = UserHelper.GetUserIp(),
        //        PageUrl = UserHelper.GetRequestUrl(),
        //        OrganizationID = UserHelper.GetUserInOrganizationID(),
        //    });
        //}
        //public static void Operate(object targetID, string actionInfo)
        //{
        //    System.Reflection.MethodBase methodInfo = new System.Diagnostics.StackFrame(1).GetMethod();
        //    ILog logger = LogManager.GetLogger(methodInfo.DeclaringType);
        //    logger.Fatal(new BusinessLog()
        //    {
        //        ModuleName = methodInfo.DeclaringType.FullName,
        //        MethodName = methodInfo.Name,
        //        TargetID = targetID,
        //        Action = actionInfo,
        //        LoginName = UserHelper.GetUserIdentity(),
        //        ServerName = UserHelper.GetServerName(),
        //        ClientIP = UserHelper.GetUserIp(),
        //        PageUrl = UserHelper.GetRequestUrl(),
        //        OrganizationID = UserHelper.GetUserInOrganizationID(),
        //    });
        //}

        //public static void AddOperate(object newEntity)
        //{
        //    //System.Reflection.MethodBase methodInfo = new System.Diagnostics.StackFrame(1).GetMethod();
        //    //ILog logger = LogManager.GetLogger(methodInfo.DeclaringType);
        //    //logger.Fatal(new BusinessLog()
        //    //{
        //    //    ModuleName = methodInfo.DeclaringType.FullName,
        //    //    MethodName = methodInfo.Name,
        //    //    TargetID = "",
        //    //    Action = "添加操作：\r\n" + newEntity.ObjectJSONSerialization(), //序列化试题
        //    //    LoginName = UserHelper.GetUserIdentity(),
        //    //    ServerName = UserHelper.GetServerName(),
        //    //    ClientIP = UserHelper.GetUserIp(),
        //    //    PageUrl = UserHelper.GetRequestUrl(),
        //    //    OrganizationID = UserHelper.GetUserInOrganizationID(),
        //    //});
        //}
        

        /// <summary>
        /// 更新日志
        /// </summary>
        /// <param name="moduleType">模块</param>
        /// <param name="originalEntity">原始数据</param>
        /// <param name="newEntity">新数据</param>
        //public static void UpdateOperate(object originalEntity, object newEntity)
        //{
        //    //System.Reflection.MethodBase methodInfo = new System.Diagnostics.StackFrame(1).GetMethod();
        //    //ILog logger = LogManager.GetLogger(methodInfo.DeclaringType);
        //    //logger.Fatal(new BusinessLog()
        //    //{
        //    //    ModuleName = methodInfo.DeclaringType.FullName,
        //    //    MethodName = methodInfo.Name,
        //    //    TargetID = "",
        //    //    Action = "更新操作：\r\n" + "原始数据:\r\n" + originalEntity.ObjectJSONSerialization() + "\r\n更新数据：\r\n" + newEntity.ObjectJSONSerialization(),//序列化实体
        //    //    LoginName = UserHelper.GetUserIdentity(),
        //    //    ServerName = UserHelper.GetServerName(),
        //    //    ClientIP = UserHelper.GetUserIp(),
        //    //    PageUrl = UserHelper.GetRequestUrl(),
        //    //    OrganizationID = UserHelper.GetUserInOrganizationID(),
        //    //});
        //}

        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="moduleType">模块</param>
        /// <param name="originalEntity">原始数据</param>
        //public static void DeleteOperate(object originalEntity)
        //{
        //    //System.Reflection.MethodBase methodInfo = new System.Diagnostics.StackFrame(1).GetMethod();
        //    //ILog logger = LogManager.GetLogger(methodInfo.DeclaringType);
        //    //logger.Fatal(new BusinessLog()
        //    //{
        //    //    ModuleName = methodInfo.DeclaringType.FullName,
        //    //    MethodName = methodInfo.Name,
        //    //    TargetID = "",
        //    //    Action = "删除操作：\r\n" + originalEntity.ObjectJSONSerialization(),//序列化试题
        //    //    LoginName = UserHelper.GetUserIdentity(),
        //    //    ServerName = UserHelper.GetServerName(),
        //    //    ClientIP = UserHelper.GetUserIp(),
        //    //    PageUrl = UserHelper.GetRequestUrl(),
        //    //    OrganizationID = UserHelper.GetUserInOrganizationID(),
        //    //});
        //}


    }
}
